{include file="public/layout" /}

<body class="bodystyle" style="cursor: default; -moz-user-select: inherit;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
{include file="member/left" /}
<div class="page min-hg-c-10" style="min-width: auto; margin-left: 100px;">
    <div class="flexigrid flexigrid-xin member_lt">
        <div class="mDiv pt0">
            <div class="ftitle">
                {eq name="'Member@users_batch_add'|is_check_access" value="1"}
                    <div class="fbutton">
                        <a href="javascript:void(0);" data-href="{:url('Member/users_batch_add')}" onclick="openFullframe(this, '新增会员','60%','80%');">
                            <div class="add" title="新增会员">
                                <span><i class="layui-icon layui-icon-addition"></i>新增会员</span>
                            </div>
                        </a>
                    </div>
                {/eq}
            </div>
        </div>
        <div class="header-bar mb20">
            <div class="more">
                <div class="search">
                    <div class="content">
                        <form id="postForm" action="{:url('Member/users_index')}" method="get" onsubmit="layer_loading('正在处理');" style="display: unset;">
                            {$searchform.hidden|default=''}
                            <div class="ey-form-item"><label class="users-form-item-label">关键词：</label>
                                <div class="users-form-item-content">
                                    <div class="users-select">
                                        <div tabindex="0" class="users-select-selection">
                                            <div class="sDiv2">
                                                <input type="text" size="50" name="keywords" value="{$Request.param.keywords}" class="qsbox w220" placeholder="会员名/昵称/手机号/邮箱/会员ID">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            
                            <div class="ey-form-item">
                                <label class="users-form-item-label">会员来源：</label>
                                <div class="users-form-item-content">
                                    <div class="users-select">
                                        <div tabindex="0" class="users-select-selection">
                                            <div>
                                                <select name="source">
                                                    <option value="0">全部</option>
                                                    <option value="1" {eq name="$Request.param.source" value="1"}selected{/eq}>PC端</option>
                                                    <option value="2" {eq name="$Request.param.source" value="2"}selected{/eq}>H5</option>
                                                    <option value="3" {eq name="$Request.param.source" value="3"}selected{/eq}>微信公众号</option>
                                                    <option value="4" {eq name="$Request.param.source" value="4"}selected{/eq}>微信小程序</option>
                                                    <!-- <option value="5" {eq name="$Request.param.source" value="5"}selected{/eq}>百度小程序</option> -->
                                                    <option value="6" {eq name="$Request.param.source" value="6"}selected{/eq}>抖音小程序</option>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="ey-form-item"><label class="users-form-item-label">会员等级：</label>
                                <div class="users-form-item-content">
                                    <div class="users-select">
                                        <div tabindex="0" class="users-select-selection">
                                            <div class="">
                                                <select name="level" id="level">
                                                    <option value="0">全部</option>
                                                    {foreach name="$level" item="vo" key="k" }
                                                    <option value="{$vo.level_id}" {eq name="$Request.param.level" value="$vo.level_id"}selected{/eq}>{$vo.level_name}</option>
                                                    {/foreach}
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="ey-form-item"><label class="users-form-item-label">注册时间：</label>
                                <div class="users-form-item-content">
                                    <div class="users-select">
                                        <div tabindex="0" class="users-select-selection">
                                            <div class="sDiv2">
                                                <input type="text" name="add_time" id="eYLaydateTimeLinkage" data-max_date="{php}echo date('Y-m-d');{/php}" autocomplete="off"  class="qsbox" placeholder="会员注册时间" lay-key="1" style="width: 220px;" value="{$Request.param.add_time}">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </form>
                        <div class="ey-form-item ml20">
                            <div class="users-form-item-content">
                                <span class="bt-xin" onclick="usersQuery();">查询</span>
                                <span class="bt-xin-no" onclick="usersQuery('reset');">重置</span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="flexigrid">
        <div class="hDiv">
            <div class="hDivBox">
                <table cellspacing="0" cellpadding="0" style="width: 100%">
                    <thead>
                        <tr>
                            <th class="w40"> <div class="tc">ID</div> </th>
                            <th class=""> <div class="tl text-l10">会员</div> </th>
                            {if condition="$php_servicemeal >= 2"}
                            <th class="w120">
                                <div class="tc sort_style">
                                    <a href="{:getArchivesSortUrl('users_money')}" >账户余额&nbsp;<i {eq name='$Request.param.orderby' value='users_money'}{eq name='$Request.param.orderway' value='asc'}class="asc"{else /}class="desc"{/eq}{/eq}></i></a>
                                </div>
                            </th>
                            <th class="w120">
                                <div class="tc sort_style">
                                    <a href="{:getArchivesSortUrl('scores')}" >积分&nbsp;<i {eq name='$Request.param.orderby' value='scores'}{eq name='$Request.param.orderway' value='asc'}class="asc"{else /}class="desc"{/eq}{/eq}></i></a>
                                </div>
                            </th>
                            {/if}
                            <th class="w120">
                                <div class="tc">累计成交订单</div>
                            <th class="w120">
                                <div class="tc">累计消费金额</div>
                            </th>
                            <th class="w150"> <div class="tc">注册日期</div> </th>
                            <th class="w120"> <div class="tc">操作</div> </th>
                        </tr>
                    </thead>
                </table>
            </div>
        </div>
        <div class="bDiv" style="height: auto;">
            <div id="flexigrid" cellpadding="0" cellspacing="0" border="0">
                <table style="width: 100%">
                    <tbody>
                    {empty name="list"}
                        <div class="no-data">
                            <div class="no_row">
                                <div class="no_pic"><img src="__SKIN__/images/null-data.png"></div>
                            </div>
                        </div>
                    {else/}
                        {foreach name="list" item="vo" key="k" }
                        <tr>
                            <!-- <td class="sign">
                                <div class="w40 tc">
                                    <input type="checkbox" autocomplete="off" name="ids[]" value="{$vo.users_id}">
                                </div>
                            </td> -->
                            <td class="sort">
                                <div class="w40 tc">{$vo.users_id}</div>
                            </td>
                            <td style="width: 100%">
                                <div class="users-list-t-p">
                                    <div class="users-list-pic pd0">
                                        <img id="img_head_pic" style="width: 40px;height: 40px; margin-right: 5px;" src="{$vo.head_pic|get_head_pic=###,false,$vo['sex']}" />
                                        <div class="users-list-source">
                                            <!-- {eq name='$vo.source' value='2'}
                                            <div class="users-source-l"><i class="iconfont e-ly-h5 yes"></i></div>
                                            {/eq} -->
                                            {if condition="!empty($vo.source) && 3 === intval($vo.source)"}
                                            <div class="users-source-l">
                                                <i class="iconfont e-ly-gzh yes"></i>
                                            </div>
                                            {elseif condition="!empty($vo.source) && 4 === intval($vo.source)"}
                                            <div class="users-source-l">
                                                <i class="iconfont e-ly-wxxcx yes"></i>
                                            </div>
                                            {elseif condition="!empty($vo.source) && 5 === intval($vo.source)"}
                                            <div class="users-source-l">
                                                <i class="iconfont e-ly-bd yes"></i>
                                            </div>
                                            {elseif condition="!empty($vo.source) && 6 === intval($vo.source)"}
                                            <div class="users-source-l">
                                                <i class="iconfont e-ly-dy yes"></i>
                                            </div>
                                            {elseif condition="!empty($vo.source) && 1 === intval($vo.source)"}
                                            <div class="users-source-l">
                                                <i class="iconfont e-ly-pc yes"></i>
                                            </div>
                                            {/if}
                                        </div>
                                    </div>
                                    
                                    <div class="pd0 text-left">
                                        <p style="margin-top: -5px;margin-left: 5px;">
                                            {eq name="'Member@users_edit'|is_check_access" value="1"}
                                            <a href="{:url('Member/users_edit',array('id'=>$vo['users_id']))}">{$vo.nickname|default=$vo.username}</a>
                                            {else /}
                                            {$vo.nickname|default=$vo.username}
                                            {/eq}
                                        </p>
                                        <p class="binding">
                                            <span class="level">{$vo.level_name}</span>
                                        </p>
                                    </div>
                                </div>
                            </td>
                            {if condition="$php_servicemeal >= 2"}
                            <td>
                                <div class="w120 tc">
                                    ￥{$vo.users_money}
                                </div>
                            </td>
                            <td>
                                <div class="w120 tc">
                                    {$vo.scores}
                                </div>
                            </td>
                            {/if}
                            <td>
                                <div class="w120 tc">
                                    {$vo.users_order_count}
                                </div>
                            </td>
                            <td>
                                <div class="w120 tc">
                                    ￥{$vo.users_order_amount}
                                </div>
                            </td>
                            <td>
                                <div class="w150 tc">
                                    <p>{$vo.reg_time|date='Y-m-d H:i:s',###}</p>
                                </div>
                            </td>
                            <td class="operation">
                                <div class="w120 tc">
                                    {eq name="'Member@users_edit'|is_check_access" value="1"}
                                    <a href="{:url('Member/users_edit',array('id'=>$vo['users_id']))}" class="btn blue">详情</a>
                                    {/eq}
                                    <!-- <i></i>
                                    <a class="btn red"  href="javascript:void(0);" data-url="{:url('Member/users_del')}" data-id="{$vo.users_id}" data-admin_id="{$vo.admin_id}" data-username="{$vo.username}" onclick="usersdel(this);">删除</a> -->
                                </div>
                            </td>
                        </tr>
                        {/foreach}
                    {/empty}
                    </tbody>
                </table>
            </div>
            <div class="iDiv" style="display: none;"></div>
        </div>
        {notempty name="list"}
        <div class="footer-oper">
			{include file="public/page" /}
            <div style="clear:both"></div>
        </div>
        {/notempty}
	</div>
</div>

<script type="text/javascript">
    $(function(){
        $('input[name*=ids]').click(function() {
            if ($('input[name*=ids]').length == $('input[name*=ids]:checked').length) {
                $('.checkAll').prop('checked', true);
            } else {
                $('.checkAll').prop('checked', false);
            }
        });

        $('input[type=checkbox].checkAll').click(function() {
            $('input[type=checkbox]').prop('checked', this.checked);
        });
    });

    $(document).keydown(function(event) {
        if (13 === parseInt(event.keyCode)) usersQuery();
    });

    // 会员搜索查询
    function usersQuery(isReset) {
        if (isReset && 'reset' == isReset) {
            window.location.href = "{:url('Member/users_index')}";
        } else {
            $('#postForm').submit();
        }
    }

    // 删除
    function usersdel(obj){
        var admin_id = $(obj).data('admin_id');
        if (0 < admin_id) {
            var title = "系统管理员前台ID，删除不可恢复？<br/>包含该会员数据有(订单、投稿、问答、留言等)";
        } else {
            var title = "是否删除该会员？删除后不可找回。<br/>包含该会员数据有(订单、投稿、问答、留言等)";
        }
        layer.confirm(title, {
            shade: layer_shade,
            area: ['480px', '200px'],
            move: false,
            title: '提示',//$(obj).attr('data-username'),
            btnAlign:'r',
            closeBtn: 3,
            btn: ['确定','取消'], //按钮
            success: function () {
                  $(".layui-layer-content").css('text-align', 'left');
              }
        }, function(){
            layer_loading('正在处理');
            // 确定
            $.ajax({
                type : 'post',
                url : $(obj).attr('data-url'),
                data : {del_id:$(obj).attr('data-id'), _ajax:1},
                dataType : 'json',
                success : function(data){
                    layer.closeAll();
                    if(data.code == 1){
                        layer.msg(data.msg, {icon: 1});
                        window.location.reload();
                    }else{
                        layer.alert(data.msg, {icon: 2, title:false});
                    }
                }
            })
        }, function(index){
            layer.close(index);
        });
        return false;
    }

    /**
     * 批量删除提交
     */
    function batch_del(obj, name) {
        var a = [];
        $('input[name^='+name+']').each(function(i,o){
            if($(o).is(':checked')){
                a.push($(o).val());
            }
        })
        if(a.length == 0){
            layer.alert('请至少选择一项', {
                shade: layer_shade,
                area: ['480px', '190px'],
                move: false,
                title: '提示',
                btnAlign:'r',
                closeBtn: 3,
                success: function () {
                      $(".layui-layer-content").css('text-align', 'left');
                  }
            });
            return;
        }
        // 删除按钮
        layer.confirm('确认批量彻底删除？<br/>包含该会员数据有(订单、投稿、问答、留言等)', {
            shade: layer_shade,
            area: ['480px', '190px'],
            move: false,
            title: '提示',
            btnAlign:'r',
            closeBtn: 3,
            btn: ['确定', '取消'] ,//按钮
            success: function () {
                  $(".layui-layer-content").css('text-align', 'left');
              }
        }, function () {
            layer_loading('正在处理');
            $.ajax({
                type: "POST",
                url: $(obj).attr('data-url'),
                data: {del_id:a, _ajax:1},
                dataType: 'json',
                success: function (data) {
                    layer.closeAll();
                    if(data.code == 1){
                        layer.msg(data.msg, {icon: 1});
                        window.location.reload();
                    }else{
                        layer.alert(data.msg, {icon: 2, title:false});
                    }
                },
                error:function(e){
                    layer.closeAll();
                    layer.alert(e.responseText, {icon: 2, title:false});
                }
            });
        }, function (index) {
            layer.closeAll(index);
        });
    }

    function changeIsActivation(table,id_name,id_value,field,obj) {
        var is_activation = $(obj).data('value');
        console.log(is_activation)
        var title = '';
        if (0 == is_activation) {
            title = '确认关闭激活吗?关闭后前台该会员将无法登录!';
        } else if (1 == is_activation) {
            title = '确认激活吗?激活后会员将可以前台登录';
        }

        // 删除按钮
        layer.confirm(title, {
            shade: layer_shade,
            area: ['480px', '190px'],
            move: false,
            title: '提示',
            btnAlign:'r',
            closeBtn: 3,
            btn: ['确定', '取消'] ,//按钮
            success: function () {
                $(".layui-layer-content").css('text-align', 'left');
            }
        }, function () {
            changeTableVal(table,id_name,id_value,field,obj);
            layer.closeAll();
        }, function (index) {
            layer.closeAll();
        });

    }
</script>

<!-- 日期联动选择js文件 start -->
<script type="text/javascript" src="__PUBLIC__/static/common/js/ey_laydate_time_linkage.js?v={$version}"></script>
<!-- 日期联动选择js文件 end -->
{include file="public/footer" /}